package top.zhangjianyong.tools.config.mybatis;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import top.zhangjianyong.tools.utils.IdWorker;


public class CustomIdGenerator implements IdentifierGenerator {

    private final IdWorker idWorker;


    public CustomIdGenerator(long workerId,
                             long dataCenterId,
                             long sequence) {
        idWorker = new IdWorker(workerId, dataCenterId, sequence);
    }

    @Override
    public Number nextId(Object entity) {
        return idWorker.nextId();
    }
}
